package com.lxyk.service.student.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lxyk.dao.student.StudentDao;
import com.lxyk.domain.StudentVO;
import com.lxyk.service.student.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentDao studentDao;

    @Override
    public PageInfo<StudentVO> findStudentByCid(Integer cid, Integer pageNum, Integer pageSize) {
        pageNum = pageNum != null ? pageNum : 1;
        pageSize = pageSize != null ? pageSize : 10;
        PageHelper.startPage(pageNum, pageSize);
        List<StudentVO> list = studentDao.findStudentByCid(cid);
        return new PageInfo(list);
    }

    @Override
    public PageInfo<StudentVO> findAllStudent(Integer pageNum, Integer pageSize) {
        pageNum = pageNum != null ? pageNum : 1;
        pageSize = pageSize != null ? pageSize : 10;
        PageHelper.startPage(pageNum, pageSize);
        List<StudentVO> list = studentDao.findAllStudent();
        return new PageInfo(list);
    }

}
